diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 3a41aa43e406..d9e7c5efdf57 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -463,11 +463,8 @@ append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
 if (COMPILER_RT_USE_BUILTINS_LIBRARY)
   string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
 else()
-  if (ANDROID)
-    append_list_if(COMPILER_RT_HAS_GCC_LIB gcc SANITIZER_COMMON_LINK_LIBS)
-  else()
-    append_list_if(COMPILER_RT_HAS_GCC_S_LIB gcc_s SANITIZER_COMMON_LINK_LIBS)
-  endif()
+  append_list_if(COMPILER_RT_HAS_LIBC gcc SANITIZER_COMMON_LINK_LIBS)
+  append_list_if(COMPILER_RT_HAS_LIBC stdc++ SANITIZER_COMMON_LINK_LIBS)
 endif()
 
 append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS)
